package com.fast.alden.portal.web.controller;

import com.fast.alden.common.exception.BizException;
import com.fast.alden.common.exception.BizExceptionEnum;
import com.fast.alden.portal.util.PortalSecurityUtils;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloPortalController {
    @GetMapping(value = "/hello", produces = {MediaType.APPLICATION_JSON_VALUE})
    public String hello() {
        return "Hello world!";
    }

    @GetMapping(value = "/hello2", produces = {MediaType.APPLICATION_JSON_VALUE})
    public String hello2() {
        if (PortalSecurityUtils.getCurrentUser() == null) {
            throw new BizException(BizExceptionEnum.USER_DOSE_NOT_LOGGED_IN);
        }
        return "Hello world2!";
    }
}
